package com.iraeta.controller;


import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.iraeta.entity.main.WeiXinUser;
import com.iraeta.service.hik.IWeiXinUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 微信用户Controller
 * 
 * @author 陈宾
 * @date 2023-10-06
 */
@RestController
@RequestMapping("/iraeta/weixinuser")
public class WeiXinUserController extends BaseController
{
    @Autowired
    private IWeiXinUserService weiXinUserService;

    /**
     * 查询微信用户列表
     */
    @RequestMapping("/list")
    public String list(@RequestBody JSONObject jo)
    {
        WeiXinUser weiXinUser = new WeiXinUser();
        weiXinUser.setName(jo.getString("name"));
        this.pageSet(jo);
        List<WeiXinUser> list = weiXinUserService.selectWeiXinUserList(weiXinUser);
        PageInfo<WeiXinUser> WeiXinUserPageInfo = this.getPageInfo(list);
        return success(WeiXinUserPageInfo);
    }

    /**
     * 获取微信用户详细信息
     */
    @GetMapping(value = "/{id}")
    public String getInfo(@PathVariable("id") Long id)
    {
        weiXinUserService.selectWeiXinUserById(id);
        return success();
    }

    /**
     * 新增微信用户
     */
    @PostMapping
    public String add(@RequestBody WeiXinUser weiXinUser)
    {
        weiXinUserService.insertWeiXinUser(weiXinUser);
        return success();
    }

    /**
     * 修改微信用户
     */
    @PutMapping
    public String edit(@RequestBody WeiXinUser weiXinUser)
    {
        weiXinUserService.updateWeiXinUser(weiXinUser);
        return success();
    }


    /**
     * 删除微信用户
     */
	@DeleteMapping("/{ids}")
    public String remove(@PathVariable Long[] ids)
    {
        weiXinUserService.deleteWeiXinUserByIds(ids);
        return success();
    }
}
